package com.tz.platform.tag.show;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.tz.platform.utils.DateUtil;
import com.tz.platform.utils.StringUtil;

/**
 * 将时间戳转成时间
 * ClassName: showTimeTrans <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * date: 2016年5月23日 下午6:04:32 <br/>
 *
 * @author changhz
 * @version
 */
@SuppressWarnings("serial")
public class ShowTimeTrans extends TagSupport {

	private String timeStamp; // 时间戳
	private String parttern;  // 时间格式

	public String getTimeStamp() {
		return timeStamp;
	}

	public void setTimeStamp(String timeStamp) {
		this.timeStamp = timeStamp;
	}

	public String getParttern() {
		return parttern;
	}

	public void setParttern(String parttern) {
		this.parttern = parttern;
	}
	
	@Override
	public int doStartTag() throws JspException {
		String dateStr = "";
		if (!StringUtil.msIsEmpty(timeStamp) && !"0".equals(timeStamp)) {
			dateStr = DateUtil.timeStampToStringDate(Long.valueOf(timeStamp), parttern);
		}
		try {
			pageContext.getOut().write(dateStr);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_BODY_INCLUDE;
	}

	
}